home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
021-030
/
amok23
/
dumpdiff
/
dumpdiff.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
4KB
|
179 lines
(*---------------------------------------------------------------------------
:Program. DumpDiff.mod
:Author. Fridtjof Siebert
:Address. Nobileweg 67, D-7000 Stuttgart 40
:Phone. (0)711/822509
:Shortcut. [fbs]
:Version. 1.0
:Date. 13-Aug-89
:Copyright. PD
:Language. Modula-II
:Translator. M2Amiga v3.2
:History. created from Bernd Preusing's Diff Program
:Contents. Show differences of two files
---------------------------------------------------------------------------*)
MODULE DumpDiff;
FROM SYSTEM IMPORT
ADR, ADDRESS, CAST;
FROM InOut IMPORT
Write, WriteString, WriteLn, WriteHex, WriteInt;
FROM Arts IMPORT
Assert;
FROM FileSystem IMPORT
File, Lookup, Close, ReadBytes, Response, Length;
FROM Arguments IMPORT
NumArgs, GetArg;
FROM Heap IMPORT Allocate, Deallocate;
TYPE wp = PROCEDURE(CHAR);
VAR i,l1,l2,errs:LONGINT;
f1,f2:File;
len:INTEGER;
s1,s2:ARRAY[0..50] OF CHAR;
a1,a2: POINTER TO CHAR;
equalmode: BOOLEAN;
S1,S2,ch1,ch2: ARRAY [0..255] OF CHAR;
L1,L2,cL1,cL2: INTEGER;
PROCEDURE write1(c: CHAR);
BEGIN
S1[L1] := c; INC(L1);
END write1;
PROCEDURE write2(c: CHAR);
BEGIN
S2[L2] := c; INC(L2);
END write2;
PROCEDURE writec2(c: CHAR);
BEGIN
ch2[cL2] := c; INC(cL2);
END writec2;
PROCEDURE writec1(c: CHAR);
BEGIN
ch1[cL1] := c; INC(cL1);
END writec1;
PROCEDURE write(c: CHAR);
BEGIN
write1(c); write2(c); writec1(c); writec2(c);
END write;
PROCEDURE Mode(ok: BOOLEAN);
BEGIN
IF ok # equalmode THEN
equalmode := ok;
write(33C); write("[");
IF ok THEN write("0") ELSE write("3"); write("3") END;
write("m");
END;
IF NOT ok THEN INC(errs) END;
END Mode;
PROCEDURE whex(c: CHAR; p: wp);
PROCEDURE whexdig(i: INTEGER);
BEGIN
IF i>9 THEN INC(i,55) ELSE INC(i,30H) END;
p(CHR(i));
END whexdig;
BEGIN
whexdig(ORD(c) DIV 16); whexdig(ORD(c) MOD 16);
END whex;
PROCEDURE Out();
BEGIN
Mode(TRUE); WriteHex(i-7,8); WriteString(": ");
S1[L1] := 0C; WriteString(S1); Write(" "); L1 := 0; ch1[cL1] := 0C; WriteString(ch1); cL1 := 0;
WriteString(" | ");
S2[L2] := 0C; WriteString(S2); Write(" "); L2 := 0; ch2[cL2] := 0C; WriteString(ch2); cL2 := 0;
WriteLn;
END Out;
PROCEDURE writehex(c1,c2: CHAR);
PROCEDURE ascii(c: CHAR): CHAR;
BEGIN
CASE c OF 40C..177C,240C..377C: RETURN c ELSE RETURN "." END;
END ascii;
BEGIN
whex(c1,write1); writec1(ascii(c1));
whex(c2,write2); writec2(ascii(c2));
IF i MOD 4 = 3 THEN write1(" "); write2(" ") END;
IF (i MOD 8 = 7) THEN Out END;
END writehex;
BEGIN
i:=NumArgs();
errs:=0; equalmode := TRUE;
IF i#2 THEN
WriteString("usage: DumpDiff file1 file2");
WriteLn;
ELSE
GetArg(1,s1,len);
GetArg(2,s2,len);
Lookup(f1,s1,0,FALSE);
Assert(f1.res=done,ADR("1.File nicht zu öffnen."));
Lookup(f2,s2,0,FALSE);
IF f2.res#done THEN
Close(f1);
Assert(f2.res=done,ADR("2.File nicht zu öffnen."));
END;
Length(f1,l1);
Length(f2,l2);
Allocate(a1,l1);
Assert(a1#NIL,ADR("Nicht genug Speicher für File1"));
Allocate(a2,l2);
Assert(a2#NIL,ADR("Nicht genug Speicher für File1"));
ReadBytes(f1,a1,l1,i);
Assert(f1.res=done,ADR("Lesefehler File1"));
ReadBytes(f2,a2,l2,i);
Assert(f2.res=done,ADR("Lesefehler File2"));
Close(f1); Close(f2);
i:=0;
REPEAT
Mode(CAST(CHAR,a1^)=CAST(CHAR,a2^));
writehex(a1^,a2^);
INC(a1); INC(a2);
INC(i); DEC(l1); DEC(l2);
UNTIL (l1<=0) OR (l2<=0);
Mode(TRUE);
IF i MOD 8 # 0 THEN
WHILE i MOD 8 # 0 DO
write1(" "); write2(" "); write(" ");
IF i MOD 4 = 3 THEN write1(" "); write2(" ") END;
INC(i)
END;
Out();
END;
IF errs#0 THEN
WriteInt(errs,5);
ELSE
WriteString("Keine");
END;
WriteString(" Unterschiede gefunden.");
WriteLn;
END;
END DumpDiff.